package com.disability_federation.mapper;

import com.disability_federation.pojo.UnpaidEnterpriseList;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 未缴费企业列表-数据库接口
 */
@Mapper
public interface MapperUnpaidEnterpriseList {

    //查询全部未缴费企业
    //默认时间升序排序
    @Select("select * from unpaid_enterprise_list.unpaid_enterprise_list order by pay_time")
    List<UnpaidEnterpriseList> query();

    //查询全部未缴费企业
    //默认时间降序排序
    @Select("select * from unpaid_enterprise_list.unpaid_enterprise_list order by pay_time desc")
    List<UnpaidEnterpriseList> queryDesc();

    //查询全部未缴费企业
    //企业名升序排序
    @Select("select * from unpaid_enterprise_list.unpaid_enterprise_list order by enterprise")
    List<UnpaidEnterpriseList> queryEnterpriseAsc();

    //查询全部未缴费企业
    //企业名降序排序
    @Select("select * from unpaid_enterprise_list.unpaid_enterprise_list order by enterprise desc")
    List<UnpaidEnterpriseList> queryEnterpriseDesc();

    //查询全部未缴费企业
    //金额升序排序
    @Select("select * from unpaid_enterprise_list.unpaid_enterprise_list order by sum")
    List<UnpaidEnterpriseList> queryMoneyAsc();

    //查询全部未缴费企业
    //金额降序排序
    @Select("select * from unpaid_enterprise_list.unpaid_enterprise_list order by sum desc")
    List<UnpaidEnterpriseList> queryMoneyDesc();

    //条件查询未缴费企业
    //默认时间升序排序
    List<UnpaidEnterpriseList> queryCondition(String enterprise, Integer sum1, Integer sum2);

    //条件查询未缴费企业
    //默认时间降序排序
    List<UnpaidEnterpriseList> queryConditionDesc(String enterprise, Integer sum1, Integer sum2);

    //条件查询未缴费企业
    //企业名升序排序
    List<UnpaidEnterpriseList> queryConditionEnterpriseAsc(String enterprise, Integer sum1, Integer sum2);

    //条件查询未缴费企业
    //企业名降序排序
    List<UnpaidEnterpriseList> queryConditionEnterpriseDesc(String enterprise, Integer sum1, Integer sum2);

    //条件查询未缴费企业
    //金额升序排序
    List<UnpaidEnterpriseList> queryConditionMoneyAsc(String enterprise, Integer sum1, Integer sum2);

    //条件查询未缴费企业
    //金额降序排序
    List<UnpaidEnterpriseList> queryConditionMoneyDesc(String enterprise, Integer sum1, Integer sum2);

    //删除某个未缴费企业
    @Delete("delete from unpaid_enterprise_list.unpaid_enterprise_list where id=#{id}")
    int delete(Integer id);

    //添加未缴费企业
    @Options(useGeneratedKeys = true, keyProperty = "id")//插入成功后，将主键值回填到mybatisUser对象中
    @Insert("insert into unpaid_enterprise_list.unpaid_enterprise_list(enterprise, address, phone, sum, pay_time)" +
            "value (#{enterprise}, #{address}, #{phone}, #{sum}, #{payTime})")
    int add(UnpaidEnterpriseList unpaidEnterpriseList);

    //更新未缴费企业
    int update(UnpaidEnterpriseList unpaidEnterpriseList);

    //批量删除未缴费企业
    int deleteBatch(Integer[] ids);
}
